package com.clkj.sunhelp.app;

import android.app.Application;

import com.clkj.sunhelp.BuildConfig;
import com.clkj.sunhelp.R;
import com.clkj.sunhelp.common.Config;
import com.clkj.sunhelp.http.HttpService;
import com.clkj.sunhelp.util.LogUtil;
import com.clkj.sunhelp.util.Res;
import com.clkj.sunhelp.util.viewutil.imageloader.PicassoImageLoader;
import com.clkj.sunhelp.util.viewutil.imageloader.PicassoPauseOnScrollListener;

import cn.finalteam.galleryfinal.CoreConfig;
import cn.finalteam.galleryfinal.FunctionConfig;
import cn.finalteam.galleryfinal.GalleryFinal;
import cn.finalteam.galleryfinal.ThemeConfig;

/**
 * Created by Administrator on 2017/3/26.
 */

public class CustomApplication extends Application {

    private static CustomApplication mInstance;

    public static CustomApplication getInstance()
    {
        return mInstance;
    }

    private HttpService httpService;
    public HttpService getHttpService() {
        if (httpService == null) {
            httpService = HttpService.Factory.create(Config.URL_BASE_IN_USE);
        }
        return httpService;
    }


    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
        /* Dexter.initialize(this);*/
        initLog();
        initGalleyFinal();

    }

    private void initLog() {
        LogUtil.isDebug = BuildConfig.DEBUG;
    }

    private void initGalleyFinal()
    {
        //设置主题
//ThemeConfig.CYAN
        ThemeConfig theme = new ThemeConfig.Builder()
                .setTitleBarBgColor(Res.getColor(R.color.color_main))
                .setTitleBarTextColor(Res.getColor(R.color.white))
                .setTitleBarIconColor(Res.getColor(R.color.white))
                .setFabNornalColor(Res.getColor(R.color.color_main))
                .setFabPressedColor(Res.getColor(R.color.color_main))
                .setCheckSelectedColor(Res.getColor(R.color.color_main))
                .build();


        //配置功能
       /* FunctionConfig functionConfig = new FunctionConfig.Builder()
                .setEnableCamera(true)
                .setEnableEdit(true)
                .setEnableCrop(true)
                .setEnableRotate(true)
                .setCropSquare(true)
                .setEnablePreview(true)
                .build();*/
        FunctionConfig functionConfig = new FunctionConfig.Builder()
                .setEnableCamera(true)
                .setEnablePreview(true)
                .build();

        PicassoImageLoader picassoImageLoader = new PicassoImageLoader();

        CoreConfig coreConfig = new CoreConfig.Builder(this, new PicassoImageLoader(), theme)
                .setFunctionConfig(functionConfig)
                .setPauseOnScrollListener(new PicassoPauseOnScrollListener(false, true))
                .build();
        GalleryFinal.init(coreConfig);

    }
}
